#include <stdio.h>

void p1() {
    char uc = 0xff;
    printf("p1\n");
    printf("unsigned char %d \n", uc++);
    signed char sc = 0x7f;//整型溢出处理方式 对2^(8*sizeof(type))作模运算
    printf("signed char %d ++ %d \n", 0x7f, ++sc);//整型溢出处理方式 对2^(8*sizeof(type))作模运算
    float max = 1.0e38;
    max = max * 10;
    printf("overflow float = %e\n", max); // 上溢 inf（无穷大）
    float min = 0.1234e-39;
    min = min / 1000;
    printf("underflow  = %e\n", min); // 下溢  失去精度
    printf("\n");
}

void p2(unsigned char val) {
    printf("p2.c\n");
    printf("%d to char = %c\n", val, val);
    printf("\n");
}

void p3() {
    printf("p3\n");
    printf("发出一声警报\n");
    printf("\n");
}

void p4() {
    printf("p4\n");
    float value;
    printf("Enter a float-point value:");
    scanf("%f", &value);
    printf("%f\n", value);
    printf("%e\n", value);
    printf("%a\n", value);
    printf("\n");
}

void p5() {
    printf("p5\n");
    short value;
    const float divisor = 3.156e7;
    printf("Enter your age :");
    scanf("%hd", &value);
    float seconds = divisor * value;
    printf("age to seconds is %e", seconds);
    printf("\n");
}

void p6() {
    const double weight = 3.0e-23;
    const int quart_weight = 950;
    int quart_value;
    printf("输入夸脱数量:");
    scanf("%d", &quart_value);
    float number = quart_value * quart_weight / weight;
    printf("水分子数量是%e\n", number);
}

void p7() {
    const float divisor = 2.54;
    float height;
    printf("输入你的升高单位厘米:");
    scanf("%f", &height);
    float inch = height / divisor;
    printf("你的身高是%f英寸\n", inch);
}

void p8() {
    const float pttobei = 2.0f;
    const float beitogs = 8.0f;
    const float gstodts = 2.0f;
    const float dtstocs = 3.0f;
    float bei;
    printf("输入杯数:");
    scanf("%f", &bei);
    float pt = bei / pttobei;
    float gs = bei * beitogs;
    float dts = gs * gstodts;
    float cs = dts * dtstocs;
    printf("%3.2f杯数==%3.2f品脱==%3.2f谷司==%3.2f大汤勺==%3.2f茶勺\n", bei, pt, gs, dts, cs);
}

int main() {
//    p1();
//    p2.c(66);
//    p3();
//    p4();
//p5();
//p6();
//    p7();
    p8();
}